package com.itboye.sunsun.adapter;

import java.util.Date;
import java.util.List;

import com.itboye.sunsunhome.R;
import com.itboye.sunsun.application.App;
import com.itboye.sunsun.beans.MessageBean;
import com.itboye.sunsun.message.ui.MyMessageActivity;
import com.itboye.sunsun.utils.LongParse;

import android.app.Activity;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import u.aly.da;

public class SystemAnnounceAdapter extends BaseAdapter {

	 
	List<MessageBean> dataList;
	 
	public SystemAnnounceAdapter(List<MessageBean> dataList     ) {
		// TODO Auto-generated constructor stub
		this.dataList=dataList;
		 
	}

	@Override
	public int getCount() {
		
		return dataList.size();
	}

	@Override
	public Object getItem(int position) {
		
		return null;
	}

	@Override
	public long getItemId(int position) {
		
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if (convertView==null) {
			convertView=LayoutInflater.from(App.ctx).inflate(R.layout.item_system_announce	, null);
			holder=new ViewHolder();
			holder.time=(TextView) convertView.findViewById(R.id.time);
			holder.title=(TextView) convertView.findViewById(R.id.title);
			holder.summery=(TextView) convertView.findViewById(R.id.summery);
			holder.more=(TextView) convertView.findViewById(R.id.more);
			convertView.setTag(holder);
			
			 
		}else{
			holder=(ViewHolder) convertView.getTag();
		}
		MessageBean bean=dataList.get(position);
		 
		holder.time.setText(new Date(LongParse.parse(bean.getCreateTime(), 0)*1000).toLocaleString());
		 
		holder.title.setText(bean.getTitle());
		holder.summery.setText(bean.getSummary());
		
		holder.more.setTag(bean.getContent());
		return convertView;
	}

	class ViewHolder{
		TextView time;
		TextView title;
		TextView summery;
		
		TextView more;
	}
}
